const express = require('express');

const chatRouter = express.Router();
const chatDao = require('../dao/chatDao');

//获取所有聊天记录
chatRouter.get('/getAllChatHistory', async (req, res) => {
    const result = await chatDao.getAllChatHistory();
    res.send(result);
});
chatRouter.get('/getShopCar', async (req, res) => {
    const result = await chatDao.getShopCar();
    res.send(result);
});
chatRouter.get('/addNumShopCar', async (req, res) => {
    const result = await chatDao.addNumShopCar();
    res.send(result);
});
chatRouter.post('/addChatHistory', async (req, res) => {
    const body = req.body;
    const result = await chatDao.addChatHistory(body.message, body.is_robot);
    console.log("【接收到的】", body.message, body.is_robot);
    res.send(body);
    // res.send(result);
});
chatRouter.post('/getStreamChat', async (req, res) => {
    const body = req.body;
    console.log("【接收到的内容-----sssss】",req.body);
    await chatDao.getChatStreamRequest(req, res);

    // res.send(body);
    // res.send(result);
});

//导出路由
module.exports = chatRouter;